package dlwntk6545.swing.outline;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class J25_JPanel2Image extends JFrame {
	public J25_JPanel2Image() {
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(150,150,450,350);
	setTitle("이미지 출력");
	setLayout(new BorderLayout());
				
	// 이미지 객체 생성

	BufferedImage image = null;
	try {
		image = ImageIO.read(getClass().getResource("/img/haha.jpg"));
	} catch (IOException e) {
		e.printStackTrace();
	}
	Image resizeimg = image.getScaledInstance(450, 350, image.SCALE_SMOOTH);
	//JLabel에 이미지 지정후 JFrame에 추가
	getContentPane().add(new JLabel(new ImageIcon(resizeimg)));
	setVisible(true);
}
	
			public static void main(String[] args){
				EventQueue.invokeLater(new Runnable() {
					
					@Override
					public void run() {
						new J25_JPanel2Image();
					}
				});
	
			}	
}